import {useTodoStore} from '@/stores/modules/todo.ts'
import {useSettingStore} from '@/stores/modules/setting.ts'
import {useWidgetStore} from '@/stores/modules/widget.ts'
import {useUserStore} from "@/stores/modules/user.ts";
import {useEngineStore} from "@/stores/modules/engine.ts";

import platformService from "@/services/platform-service.ts";
import chromeService from "@/services/chrome-service.ts";

export default function register2Global() {
    if (!window.$GLOBAL) {
        window.$GLOBAL = {
            __GLOBAL_PINIA_INSTANCE__: {},
            __GLOBAL_CHROME_SERVICE__: {},
            __GLOBAL_PLATFORM_SERVICE__: {}
        }
    }
    window.$GLOBAL.__GLOBAL_PINIA_INSTANCE__ = {
        todoInstance: useTodoStore(),
        settingInstance: useSettingStore(),
        widgetInstance: useWidgetStore(),
        userInstance: useUserStore(),
        engineInstance: useEngineStore(),
    }

    // 平台提供的api
    window.$GLOBAL.__GLOBAL_PLATFORM_SERVICE__ = platformService;
    // 谷歌浏览器提供的api
    window.$GLOBAL.__GLOBAL_CHROME_SERVICE__ = chromeService;
}
